<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <div id="app">
    <home1></home1>
  </div>
  <script src="./vue.js"></script>
  <script>
    // 定义一个子组件options
    const Child = {
      template: `
        <div>
          <h3>这是一个子组件头部</h3>
          <slot a="这是一个静态数据" :arr="arr" :msg="msg"></slot>
          <h3>这是一个子组件尾部</h3>
        </div>
      `,
      data(){
        return {
          arr: ['a', 'b', 'c', 'd'],
          msg: '子组件内部数据'
        }
      }
    }
    // data会被解析成对象，对象中的属性就是 slot 标签 自定义属性
    const Home1 = {
      template: `
        <div>
          <h2>这是home1组件</h2>
          <child>
            <div slot-scope="data">
              <ul>
                <li v-for="item in data.arr" :key="item">
                  {{ item }}
                </li>
              </ul>
              {{ data.msg }}
              {{ data.a }}
            </div>
          </child>
        </div>
      `,
      components: {
        Child
      }
    }
    Vue.component('Home1', Home1);
   
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>
</html>